﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using SnippetBox.Core.Common.Extensions;
using SnippetBox.Core.Data.Service;
using SnippetBox.Web.Models;

namespace SnippetBox.Web.Controllers
{
    public class CategoryController : Controller
    {
        public ActionResult Details(int categoryId, int? page)
        {
            CategoryService categoryService = new CategoryService();
            SnippetService snippetService = new SnippetService();
            
            var category = categoryService.GetById(categoryId);
            var snippets = snippetService.GetByCategory(categoryId, page);
            ViewData.Model = new CategoryDetailsModel(category, snippets);

            return View();
        }

    }
}
